import { create } from "zustand";
import { IUser } from "../types/user";

export const useStore = create<{
  collapsed: boolean;
  currentMenu: string;
  userInfo: IUser;
  isDark: boolean;
  setCurrentMenu: (menu: string) => void;
  updataUserInfo: (userInfo: IUser) => void;
  updateCollapsed: () => void;
  updateIsDark: (isDark: boolean) => void;
}>((set) => ({
  collapsed: false,
  currentMenu: "/dashboard",
  userInfo: {
    _id: "",
    userId: 0,
    userName: "",
    userEmail: "",
    deptId: "",
    state: 0,
    mobile: "",
    job: "",
    role: 0,
    roleList: "",
    createId: 0,
    deptName: "",
    userImg: "",
  } as IUser,
  isDark: false,
  setCurrentMenu: (menu: string) => set({ currentMenu: menu }),
  updataUserInfo: (userInfo: IUser) => set({ userInfo }),
  updateCollapsed: () => set((state) => ({ collapsed: !state.collapsed })),
  updateIsDark: (isDark) => set({ isDark }),
}));
